import { JsonHelper } from "../JsonHelper";
import { TWcsScene, TWcsSceneDeviceInfo, TWcsScenePermission } from "../models";

export class HttpService {
    public static async requestQuery(params: {types: string, where: string}) {
        var data = new Map<String, any[]>();
        if(params.types == 'kr.service.wcs.data.entity.TWcsScene') {
            var tWcsScene: TWcsScene = {
                sceneId: 'test-scene-01',
                sceneName: '测试场景',
                sceneClassType: 'BabylonScene2d',
                sceneClassPara: '{}',
                autoClear: true,
                clearColor: '#f7f2f2ff',
                ambientColor: '#33333333',
                isActived: true,
                isUsed: true,
                tWcsSceneDevice2ds: [{
                    sceneId: 'test-scene-01',
                    controlId: 'test-ui-01',
                    parentId: 'test-scene-01',
                    controlName: '测试UI',
                    controlType: 'StandardDevice2d',
                    controlPara: '',
                    brandModelId: 'test-brand-model-01',
                    backgroundId: 'test-background-01',
                    editFormType: '',
                    editFormPara: '',
                    showFormType: '',
                    showFormPara: '',
                    rotation: 0,
                    scaleX: 1,
                    scaleY: 1,
                    x: -100,
                    y: -100,
                    z: 1,
                    lengthX: 120,
                    lengthY: 60,
                    text: 'ui01',
                    font: '微软雅黑',
                    fontColor: '#ffffff',
                    textBackground: '#333333',
                    fontSize: 16,
                    textHAlignment: 0,
                    textVAlignment: 0,
                    textBorderSize: 1,
                    textBorderColor: '#00ff00',
                    backgroundColor: '#909090',
                    backgroundImage: '',
                    borderSize: 1,
                    borderColor: '#222222',
                    radius: 5,
                    arrowDirection: 'WESN',
                    arrowColor: '#00ff00',
                    isUsed: true
                }, {
                    sceneId: 'test-scene-01',
                    controlId: 'test-ui-02',
                    parentId: '',
                    controlName: '测试UI',
                    controlType: 'StandardDevice2d',
                    controlPara: '{"direction":"E"}',
                    brandModelId: 'test-brand-model-01',
                    backgroundId: 'test-background-01',
                    editFormType: '',
                    editFormPara: '',
                    showFormType: '',
                    showFormPara: '',
                    rotation: 0,
                    scaleX: 1,
                    scaleY: 1,
                    x: 0,
                    y: -100,
                    z: 1,
                    lengthX: 100,
                    lengthY: 100,
                    text: 'ui02ui02ui02ui02ui02ui02',
                    font: '微软雅黑',
                    fontColor: '#ffffff',
                    textBackground: '#00000000',
                    fontSize: 16,
                    textHAlignment: 0,
                    textVAlignment: 0,
                    textBorderSize: 1,
                    textBorderColor: '#00ff00',
                    backgroundColor: 'green',
                    backgroundImage: '',
                    borderSize: 0,
                    borderColor: '#ff0000',
                    radius: 25,
                    isUsed: true
                }, {
                    sceneId: 'test-scene-01',
                    controlId: 'test-ui-03',
                    parentId: '',
                    controlName: '测试UI',
                    controlType: 'StandardDevice2d',
                    controlPara: '{"direction":"WESN"}',
                    brandModelId: 'test-brand-model-01',
                    backgroundId: 'test-background-01',
                    editFormType: '',
                    editFormPara: '',
                    showFormType: '',
                    showFormPara: '',
                    rotation: 0,
                    scaleX: 1,
                    scaleY: 1,
                    x: 100,
                    y: -100,
                    z: 1,
                    lengthX: 100,
                    lengthY: 100,
                    text: '03',
                    font: '微软雅黑',
                    fontColor: '#ffffffee',
                    textBackground: '#00000000',
                    fontSize: 16,
                    textHAlignment: 0,
                    textVAlignment: 0,
                    textBorderSize: 1,
                    textBorderColor: '#00ff00',
                    backgroundColor: 'green',
                    backgroundImage: '',
                    borderSize: 1,
                    borderColor: '#ff0000',
                    radius: 50,
                    isUsed: true
                }],
                tWcsSceneDevice3ds: [],
                tWcsSceneCameras: [],
                tWcsSceneLights:[],
            };
            var testCount = 1200;
            var xCount = 30;
            var space = 5;
            for(var i = 0; i < testCount; i++) {
                var tWcsSceneDevice2d = JsonHelper.copyObject(tWcsScene.tWcsSceneDevice2ds[0]);
                tWcsSceneDevice2d.controlId = 'c' + i;
                tWcsSceneDevice2d.x = Math.floor(i % xCount) * (tWcsScene.tWcsSceneDevice2ds[0].lengthX + space);
                tWcsSceneDevice2d.y = Math.floor(i / xCount) * (tWcsScene.tWcsSceneDevice2ds[0].lengthY + space);
                tWcsSceneDevice2d.text = i.toString();
                tWcsScene.tWcsSceneDevice2ds.push(tWcsSceneDevice2d);
            }
            data.set('kr.service.wcs.data.entity.TWcsScene', Array.of(tWcsScene));
        } else if(params.types == 'kr.service.wcs.data.entity.TWcsScenePermission') {
            var tWcsScenePermissions :TWcsScenePermission[] = [];
            data.set('kr.service.wcs.data.entity.TWcsScenePermission', Array.of(tWcsScenePermissions));
        } else if(params.types == 'kr.service.wcs.data.entity.TWcsSceneDeviceInfo') {
            var tWcsSceneDeviceInfos :TWcsSceneDeviceInfo[] = [];
            data.set('kr.service.wcs.data.entity.TWcsSceneDeviceInfo', tWcsSceneDeviceInfos);
        } 
        return {Data: data};
    }

}